//
//  TumourViewController.m
//  QuickCure
//
//  Created by 小灰灰 on 16/9/12.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "TumourViewController.h"
#import "ViewController.h"
#import "LHillnessView.h"
#import "ZLTableViewController.h"
#import "BFZTableViewController.h"
#import "JSTableViewController.h"
#import "FocusDoctorViewController.h"

@interface TumourViewController ()
//是否确诊label
@property(nonatomic,strong)UILabel *QZtextLabel;
@property(nonatomic,weak)UIButton *selectedBtn;
@property(nonatomic,copy)NSString *btnStr;
@property(nonatomic,copy)NSString *textStr;
@property(nonatomic,strong)LHillnessView *illnessSee;

@property(nonatomic,strong)UILabel *label;
@property(nonatomic,strong)UILabel *label2;
@property(nonatomic,strong)UILabel *label3;

@property(nonatomic,strong)LHillnessView *illnessJS;
@property(nonatomic,strong)NSArray *dataArr;
@end

@implementation TumourViewController
 

-(UILabel *)label
{
    if(!_label)
    {
        _label=[[UILabel alloc] init];
    }
    return _label;
}
-(UILabel *)label2
{
    if(!_label2)
    {
        _label2=[[UILabel alloc] init];
    }
    return _label2;
}
-(UILabel *)label3
{
    if(!_label3)
    {
        _label3=[[UILabel alloc] init];
    }
    return _label3;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUI];
}


-(void)setUI
{
    self.view.backgroundColor=[UIColor colorWithRed:0.9464 green:0.9372 blue:0.9556 alpha:1.0];
    self.navigationController.navigationBar.barTintColor = kThemeColor;
    self.title = self.str;
    
    LHillnessView *view = [[LHillnessView alloc] init];
    view.frame = self.view.frame;
    [self.view addSubview:view];
    [view addLabelWithPatientInfo:@"王二狗 1000099" illnessType:self.str];
    
    //就医申请button
    UIButton *applyBtn =[[UIButton alloc] init];
    [self.view addSubview:applyBtn];
    [applyBtn setBackgroundColor:kThemeColor];
    applyBtn.layer.cornerRadius = 3;
    applyBtn.clipsToBounds = YES;
    [applyBtn addTarget:self action:@selector(applyBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [applyBtn setTitle:@"就医申请" forState:UIControlStateNormal];
    [applyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [applyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.right.mas_equalTo(self.view).offset(-10);
        make.left.mas_equalTo(self.view).offset(10);
        make.height.mas_equalTo(@40);
    }];
    //医生头像image
    UIImageView *docImg =[[UIImageView alloc] init];
    [self.view addSubview:docImg];
    docImg.image =[UIImage imageNamed:@"illness_img_person.png"];
    [docImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.width.height.equalTo(@80);
        make.bottom.mas_equalTo(applyBtn.mas_top).offset(-20);
        
    }];
    //匹配label
    UILabel *matchLabel = [[UILabel alloc] init];
    [self.view  addSubview:matchLabel];
    matchLabel.text =  @"为您匹配到：42位医生";
    matchLabel.textAlignment = NSTextAlignmentCenter;
    [matchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.height.mas_equalTo(@40);
        make.bottom.mas_equalTo(docImg.mas_top).offset(-20);
    }];
    

    
     //疾病细分view
    LHillnessView *illnessSP =[[LHillnessView alloc] init];
    [self.view addSubview:illnessSP];
     illnessSP.backgroundColor =[UIColor whiteColor];
    [illnessSP mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).offset(15);
        make.right.mas_equalTo(self.view).offset(-15);
        //封装时注意改一下
        make.top.mas_equalTo(self.view).offset(135);
        make.height.mas_equalTo(@40);
    }];
    
    [illnessSP addSubViewsWithLabelText:@"请选择疾病细分"];
    self.label = illnessSP.label;
 
 
   // 选择并发症view
    LHillnessView *illnessBF =[[LHillnessView alloc] init];
    [self.view addSubview:illnessBF];
    illnessBF.backgroundColor =[UIColor whiteColor];
    [illnessBF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).offset(15);
        make.right.mas_equalTo(self.view).offset(-15);
        make.top.mas_equalTo(illnessSP.mas_bottom).offset(10);
        make.height.mas_equalTo(@40);
    }];
    [illnessBF addSubViewsWithLabelText:@"请选择并发症（可多选）"];
    self.label3 = illnessBF.label;

    //确诊view
    LHillnessView *illnessQZ=[[LHillnessView alloc] init];
        [self.view addSubview:illnessQZ];
    illnessQZ.backgroundColor =[UIColor whiteColor];
    [illnessQZ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).offset(15);
        make.right.mas_equalTo(self.view).offset(-15);
        make.top.mas_equalTo(illnessBF.mas_bottom).offset(10);
        make.height.mas_equalTo(@40);
    }];
    

    [illnessQZ addSubViewsWithLabelText:@"是否确诊" btnStr:@"已确诊" anotherBtnStr:@"症状疑似"];
    
    //是否接受过治疗view
    LHillnessView *illnessSee=[[LHillnessView alloc] init];
    self.illnessSee = illnessSee;
    [self.view addSubview:illnessSee];
    illnessSee.backgroundColor =[UIColor whiteColor];
    [illnessSee mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).offset(15);
        make.right.mas_equalTo(self.view).offset(-15);
        make.top.mas_equalTo(illnessQZ.mas_bottom).offset(10);
        make.height.mas_equalTo(@40);
    }];
    [illnessSee addSubViewsWithLabelText:@"是否接受过治疗" btnStr:@"接受过" anotherBtnStr:@"未接受过"];
    
    //按接受过的时候出现的view
    illnessSee.textBlock = ^(NSString *textStr){
        self.textStr = textStr;
        
        if([self.textStr isEqualToString:@"接受过"])
        {
            LHillnessView *illnessJS =[[LHillnessView alloc] init];
            UITapGestureRecognizer *tap2 =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click2)];
            [illnessJS addGestureRecognizer:tap2];
            self.illnessJS = illnessJS;
            [self.view addSubview:illnessJS];
            illnessJS.backgroundColor =[UIColor whiteColor];
            [illnessJS mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(self.view).offset(15);
                make.right.mas_equalTo(self.view).offset(-15);
                make.top.mas_equalTo(self.illnessSee.mas_bottom).offset(10);
                make.height.mas_equalTo(@40);
            }];
            
            [illnessJS addSubViewsWithLabelText:@"请选择治疗方式"];
            self.label2 = illnessJS.label;
            if(self.label2)
            {
                illnessJS.label = self.label2;
            }
        }
        else{
            self.illnessJS.hidden = YES;
        }
        
        
    };
    
    //为uiview添加点击手势
    UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)];
    [illnessSP addGestureRecognizer:tap];
    
    UITapGestureRecognizer *tap1 =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click1)];
    [illnessBF addGestureRecognizer:tap1];
    
}
//点击后跳转
-(void)click
{
    //跳转到tableView
    ZLTableViewController *zlVC =[[ZLTableViewController alloc] init];
    zlVC.dataStrBlock = ^(NSString *dataStr)
    {
        [self.label setText:dataStr];
        [self.label setTextColor:[UIColor blackColor]];
 
    };
    [self.navigationController pushViewController:zlVC animated:YES];
    
}
//订阅信息
-(void)click1
{
    BFZTableViewController *BFZvc =[[BFZTableViewController alloc] init];
    BFZvc.dataStrBlock = ^(NSMutableArray *dataArr)
    {
        self.dataArr = dataArr;
        NSMutableString *muStr =[NSMutableString string];
        for (NSString *str in dataArr) {
 
            if([str isEqualToString:dataArr.lastObject])
            {
                [muStr appendFormat:@"%@",str];
            }
            else
            {
                [muStr appendFormat:@"%@、",str];
            }
        }
         if(muStr.length == 0)
        {
            [self.label3 setText:@"请选择并发症（可多选）"];
            [self.label3 setTextColor: [UIColor colorWithRed:0.8373 green:0.8333 blue:0.8414 alpha:1.0]];
            
        }else{
        [self.label3 setText:muStr.copy];
        [self.label3 setTextColor:[UIColor blackColor]];
        }
 
    };
    [self.navigationController pushViewController:BFZvc animated:YES];
    
    
}
//治疗方法
-(void)click2
{
    JSTableViewController *JSvc =[[JSTableViewController alloc] init];
    JSvc.dataStrBlock = ^(NSString *dataStr)
    {
        [self.label2 setText:dataStr];
        [self.label2 setTextColor:[UIColor blackColor]];
        
    };
    [self.navigationController pushViewController:JSvc animated:YES];
    
}
-(void)applyBtnClick
{
     
    FocusDoctorViewController *focusVC =[[FocusDoctorViewController alloc] init];
    [self.navigationController pushViewController:focusVC animated:YES];
}

@end
